<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>chart测试</title>
    <script src='https://cdn.bootcss.com/Chart.js/2.7.3/Chart.js'></script>
</head>

<body>
    <canvas id="myChart" width="500px" height="150px"></canvas>
    <script src='https://cdn.bootcss.com/Chart.js/2.7.3/Chart.js'></script>
    <script>
        var ctx = document.getElementById('myChart').getContext('2d');
        var data = {
            datasets: [{
                data: [10, 20, 30], //在这里写数据
                backgroundColor: ["red", "green", "blue"] //在这里指定颜色
            }],

            labels: [ //这里写标签，即每个数据属于哪个种类
                'label1',
                'label2',
                'label3'
            ]
        };

        var myPieChart = new Chart(ctx, {
            type: 'pie',
            data: data
        });
    </script>
</body>

</html>